package com.shopng.model;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.beans.BeanUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class SecurityUser extends User implements UserDetails
{
  /**
   * 
   */
  private static final long serialVersionUID = 4663502615081576412L;

  public SecurityUser(User suser)
  {
    if (suser != null)
    {
      BeanUtils.copyProperties(suser, this);
    }
  }
  
  @Override
  public Collection<? extends GrantedAuthority> getAuthorities()
  {
    Collection<GrantedAuthority> authorities = new ArrayList<>();
//    Set<SRole> userRoles = null;//this.getSRoles();
//    if (userRoles != null)
//    {
//      for (SRole role : userRoles)
//      {
//        SimpleGrantedAuthority authority = new SimpleGrantedAuthority(role.getName());
//        authorities.add(authority);
//      }
//    }
    return authorities;
  }
  
  @Override
  public String getPassword()
  {
    return super.getPassword();
  }
  
  @Override
  public String getUsername()
  {
    return super.getName();
  }
  
  @Override
  public boolean isAccountNonExpired()
  {
    return true;
  }
  
  @Override
  public boolean isAccountNonLocked()
  {
    return !getLocked();
  }
  
  @Override
  public boolean isCredentialsNonExpired()
  {
    return true;
  }
  
  @Override
  public boolean isEnabled()
  {
    return true;
  }
}
